package com.yanqu.road.server.cmd.specialtombrob;

import com.yanqu.road.message.YanQuMessage;


import com.yanqu.road.pb.specialtombrob.SpecialTombRobProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.specialtombrob.SpecialTombRobModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

import java.util.ArrayList;
import java.util.List;

@Cmd(code = GameProtocol.S_SPECIAL_TOMB_ROB_FINISH_GUIDE, desc = "盗墓笔记特色服完成引导")
public class SpecialTombRobFinishGuideCmd extends AbstractCommand {

    private List<Integer> steps = new ArrayList<>();

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        SpecialTombRobProto.SpecialTombRobFinishGuideReqMsg msg = SpecialTombRobProto.SpecialTombRobFinishGuideReqMsg.parseFrom(packet.getBytes());
        steps = msg.getStepList();
        return true;

    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(SpecialTombRobModule.class).finishGuide(steps);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0){
            SpecialTombRobProto.SpecialTombRobFinishGuideRespMsg.Builder respMsg = SpecialTombRobProto.SpecialTombRobFinishGuideRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(ClientProtocol.U_SPECIAL_COOK_BOY_FINISH_GUIDE, respMsg);
        }
    }
}
